import {http} from "@/service/http";
import {ModulesInfoPartial} from "@/types/module";
import {Page, PageQuery} from "@/types/response";

const prefix = '/Module'

/**
 * 批量添加模块信息
 * @param modulesInfos 模块信息集合
 */
const createModuleInfos = (modulesInfos: ModulesInfoPartial[]) => {
  return http({
    method: 'POST',
    url: `${prefix}/BatchPost`,
    data: modulesInfos
  })
}

/**
 * 添加一条信息
 * @param modulesInfo 模块信息
 */
const createModuleInfo = (modulesInfo: ModulesInfoPartial) => {
  return http({
    method: 'POST',
    url: `${prefix}/Post`,
    data: modulesInfo
  })
}



/**
 * 更新模块信息
 * @param modulesInfo 模块信息
 */
const updateModuleInfo = (modulesInfo: ModulesInfoPartial) => {
  return http({
    method: 'PUT',
    url: `${prefix}/Put`,
    data: modulesInfo
  })
}

/**
 * 删除接口信息
 * @param id
 */
const removeModuleInfo = (id: string | number) => {
  return http({
    method: 'DELETE',
    url: `${prefix}/Delete/${id}`,
  })
}


/**
 * 分页获取内容
 * @param page 内容
 */
const getModuleInfoPage = (page: PageQuery) => {
  return http<Page<ModulesInfoPartial[]>>({
    method: 'GET',
    url: `${prefix}/Get`,
    params: page
  })
}


/**
 * 获取一条信息
 * @param id
 */
const getModuleInfo = (id: number|string) => {
  return http<ModulesInfoPartial>({
    method: 'GET',
    url: `${prefix}/Get/${id}`,
  })
}
